{% extends 'base.html' %}

{% block title %}数据导入导出{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <div class="card mb-4">
            <div class="card-header">
                <h5>数据导出</h5>
            </div>
            <div class="card-body">
                <p>导出当前系统中的数据为Excel/CSV/JSON格式</p>
                <div class="d-grid gap-2">
                    <a href="{% url 'books:export_books' %}?format=xlsx" class="btn btn-success">导出图书数据(XLSX)</a>
                    <a href="{% url 'books:export_books' %}?format=csv" class="btn btn-primary">导出图书数据(CSV)</a>
                    <a href="{% url 'books:export_records' %}?format=xlsx" class="btn btn-success">导出借阅记录(XLSX)</a>
                    <a href="{% url 'books:export_records' %}?format=csv" class="btn btn-primary">导出借阅记录(CSV)</a>
                </div>
            </div>
        </div>
    </div>
    
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5>数据导入</h5>
            </div>
            <div class="card-body">
                <form method="post" enctype="multipart/form-data">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label for="import_type" class="form-label">选择导入数据类型</label>
                        <select class="form-select" id="import_type" name="import_type">
                            <option value="books">图书数据</option>
                            <option value="records">借阅记录</option>
                        </select>
                    </div>
                    <div class="mb-3">
                        <label for="file" class="form-label">选择文件</label>
                        <input class="form-control" type="file" id="file" name="file" required>
                        <div class="form-text">支持XLSX, CSV格式</div>
                    </div>
                    <button type="submit" class="btn btn-primary">导入数据</button>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}